<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>成品库资源管理</title>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<meta name="decorator" content="ani"/>
	<%@ include file="/webpage/include/bootstraptable.jsp"%>
	<%@include file="/webpage/include/treeview.jsp" %>
	<script type="text/javascript">
	$(document).ready(function() {
	$('#statRealtimeResourceTable').bootstrapTable({
		 
		  //请求方法
             method: 'get',
             //类型json
             dataType: "json",
             //显示刷新按钮
             showRefresh: true,
             //显示切换手机试图按钮
             showToggle: true,
             //显示 内容列下拉框
  	       showColumns: true,
  	       //显示到处按钮
  	       showExport: true,
  	       //显示切换分页按钮
  	       showPaginationSwitch: true,
  	       //最低显示2行
  	       minimumCountColumns: 2,
             //是否显示行间隔色
             striped: true,
             //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）     
             cache: false,    
             //是否显示分页（*）  
             pagination: true,   
              //排序方式 
             sortOrder: "asc",  
             //初始化加载第一页，默认第一页
             pageNumber:1,   
             //每页的记录行数（*）   
             pageSize: 10,  
             //可供选择的每页的行数（*）    
             pageList: [10, 25, 50, 100],
             //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据  
             url: "${ctx}/sc/realtimeresource/statRealtimeResource/data",
             //默认值为 'limit',传给服务端的参数为：limit, offset, search, sort, order Else
             //queryParamsType:'',   
             ////查询参数,每次调用是会带上这个参数，可自定义                         
             queryParams : function(params) {
             	var searchParam = $("#searchForm").serializeJSON();
             	searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
             	searchParam.pageSize = params.limit === undefined? -1 : params.limit;
             	searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+  params.order;
                 return searchParam;
             },
             //分页方式：client客户端分页，server服务端分页（*）
             sidePagination: "server",
             contextMenuTrigger:"right",//pc端 按右键弹出菜单
             contextMenuTriggerMobile:"press",//手机端 弹出菜单，click：单击， press：长按。
             contextMenu: '#context-menu',
             onContextMenuItem: function(row, $el){
                 if($el.data("item") == "edit"){
                 	window.location = "${ctx}/sc/realtimeresource/statRealtimeResource/form?id=" + row.id;
                 } else if($el.data("item") == "delete"){
                      jp.confirm('确认要删除该成品库资源记录吗？', function(){
                     	jp.loading();
                     	jp.get("${ctx}/sc/realtimeresource/statRealtimeResource/delete?id="+row.id, function(data){
                 	  		if(data.success){
                 	  			$('#statRealtimeResourceTable').bootstrapTable('refresh');
                 	  			jp.success(data.msg);
                 	  		}else{
                 	  			jp.error(data.msg);
                 	  		}
                 	  	})
                 	   
                 	});
                    
                 } 
             },
            
             onClickRow: function(row, $el){
             },
             columns: [{
		        checkbox: true
		       
		    }
			,{
		        field: 'id',
		        title: '资源编号',
		        sortable: true
		        ,formatter:function(value, row , index){
		            if(value != null){
		            	return "<a href='javascript:getTimeAxis(\""+row.id+"\")'>"+value+"</a>";
		            }
		        }
		       
		    }
			,{
		        field: 'productName',
		        title: 'sku',
		        sortable: true
		       
		    }
			,{
		        field: 'firstType',
		        title: '一级类目',
		        sortable: true
		       
		    }
			,{
		        field: 'secondType',
		        title: '二级类目',
		        sortable: true
		    }
			,{
		        field: 'thirdType',
		        title: '三级类目',
		        sortable: true
		       
		    }
			,{
		        field: 'warehouseName',
		        title: '仓库名称',
		        sortable: true
		       
		    }
		     ]
		
		});
	
	 if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端

		 
		  $('#statRealtimeResourceTable').bootstrapTable("toggleView");
		}
	  
	  $('#statRealtimeResourceTable').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
               'check-all.bs.table uncheck-all.bs.table', function () {
           $('#remove').prop('disabled', ! $('#statRealtimeResourceTable').bootstrapTable('getSelections').length);
           $('#edit').prop('disabled', $('#statRealtimeResourceTable').bootstrapTable('getSelections').length!=1);
       });
		  
		    
	  $("#search").click("click", function() {// 绑定查询按扭
		  $('#statRealtimeResourceTable').bootstrapTable('refresh');
		});
	});
	</script>
</head>
<body>
	<div class="wrapper wrapper-content">
	<div class="panel panel-primary">
	<div class="panel-heading">
		<h3 class="panel-title">成品库资源列表</h3>
	</div>
	<div class="panel-body">
		<sys:message content="${message}"/>
	
	<!-- 搜索 -->
	<div class="accordion-group">
	<div id="collapseTwo" class="accordion-body collapse">
		<div class="accordion-inner">
			<form:form id="searchForm" modelAttribute="statRealtimeResource" class="form form-horizontal well clearfix">
			 <div class="col-xs-12 col-sm-6 col-md-4">
				<label class="label-item single-overflow pull-left" title="sku名称：">sku名称：</label>
				<form:input path="productName" htmlEscape="false" maxlength="64"  class=" form-control"/>
			</div>
			 <div class="col-xs-12 col-sm-6 col-md-4">
				<label class="label-item single-overflow pull-left" title="一级类目：">一级类目：</label>
				<form:select path="categoryA"  class="form-control m-b">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('sc_category_a')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
			 <div class="col-xs-12 col-sm-6 col-md-4">
				<label class="label-item single-overflow pull-left" title="二级类目：">二级类目：</label>
				<form:select path="categoryB"  class="form-control m-b">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('sc_category_b')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
			 <div class="col-xs-12 col-sm-6 col-md-4">
				<label class="label-item single-overflow pull-left" title="三级类目：">三级类目：</label>
				<form:select path="categoryC"  class="form-control m-b">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('sc_category_c')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
			 <div class="col-xs-12 col-sm-6 col-md-4">
				<label class="label-item single-overflow pull-left" title="库房名称：">库房名称：</label>
				<form:input path="warehouseName" htmlEscape="false" maxlength="64"  class=" form-control"/>
			</div>
		 <div class="col-xs-12 col-sm-6 col-md-4">
			<div style="margin-top:26px">
			  <a  id="search" class="btn btn-primary btn-rounded  btn-bordered btn-sm"><i class="fa fa-search"></i> 查询</a>
			  <a  id="reset" class="btn btn-primary btn-rounded  btn-bordered btn-sm" ><i class="fa fa-refresh"></i> 重置</a>
			 </div>
	    </div>	
	</form:form>
	</div>
	</div>
	</div>
	
	<!-- 工具栏 -->
	<div id="toolbar">
			
	        	<a class="accordion-toggle btn btn-default" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
					<i class="fa fa-search"></i> 检索
				</a>
		    </div>
		
	<!-- 表格 -->
	<table id="statRealtimeResourceTable"   data-toolbar="#toolbar"></table>

    <!-- context menu -->
    <ul id="context-menu" class="dropdown-menu">
    	<shiro:hasPermission name="sc:realtimeresource:statRealtimeResource:edit">
        <li data-item="edit"><a>编辑</a></li>
        </shiro:hasPermission>
        <shiro:hasPermission name="sc:realtimeresource:statRealtimeResource:del">
        <li data-item="delete"><a>删除</a></li>
        </shiro:hasPermission>
        <li data-item="action1"><a>取消</a></li>
    </ul>  
	</div>
	</div>
	</div>
</body>
</html>